//
//  TLShortStoryContentTableViewCell.m
//  WXReader
//
//  Created by huaya on 2025/1/14.
//  Copyright © 2025 Andrew. All rights reserved.
//

#import "TLShortStoryContentTableViewCell.h"

@interface TLShortStoryContentTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *headLab;
@property (weak, nonatomic) IBOutlet UILabel *contentLab;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleConst;
@property (weak, nonatomic) IBOutlet UIImageView *maskView;
@end

@implementation TLShortStoryContentTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
}
- (void)setDataModel:(TLSSModel *)dataModel{
    if (dataModel) {
        _dataModel = dataModel;
        
        self.maskView.hidden = YES;
        
//        [self.contentLab attributedStringWithHTMLText:dataModel.content fontSize:18 characterSpacing:-0.025 lineSpacing:18 paragraphSpacing:17 alignment:NSTextAlignmentLeft];
        
        [self.contentLab attributedStringWithHTMLText:dataModel.content
                                             fontSize:[MKReaderCfg shared].fontSize.intValue
                                     characterSpacing:[MKReaderCfg shared].characterSpacingSize.intValue
                                          lineSpacing:[MKReaderCfg shared].lineSpacing.intValue
                                     paragraphSpacing:[MKReaderCfg shared].paragraphSpacing.intValue
                                            alignment:NSTextAlignmentLeft];
        
        self.headLab.text = dataModel.chapterName;
        
//        [self.headLab attributedStringWithHTMLText:dataModel.chapterName fontSize:20 characterSpacing:0 lineSpacing:28 paragraphSpacing:0 alignment:NSTextAlignmentCenter];
        [self.headLab attributedStringWithHTMLText:dataModel.chapterName fontSize:20 characterSpacing:0 lineSpacing:28 paragraphSpacing:0 alignment:NSTextAlignmentCenter ifExceedWidthThen:^(CGFloat requiredHeight) {
            self.titleConst.constant = requiredHeight;
            self.dataModel.tl_cellHeight += requiredHeight;
            [self layoutIfNeeded];
            MK_BLOCK_EXEC(self.reloadBlock);
        }];
        
        if ([MKReaderCfg shared].bgColorIndex.intValue == 0) {
            self.contentLab.textColor = [UIColor blackColor];
            self.headLab.textColor = [UIColor blackColor];
            [self.contentView setBackgroundColor:[UIColor hex_F6F6F6]];
        }else{
            self.contentLab.textColor = [UIColor hex_999999];
            self.headLab.textColor = [UIColor hex_999999];
            [self.contentView setBackgroundColor:[UIColor hex_191820]];
        }
    }
}
@end
